package com.foreveross.proxyip.application.offer.bean;

import java.io.Serializable;
import java.util.Date;

import javax.xml.bind.annotation.XmlRootElement;
/**
 * 代理IP对外服务提供对象
 * @author xiangsf 2013-05-31
 *
 */
@XmlRootElement(name = "ProxyIpDTO")
public class ProxyIpDTO implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -8654685418206242815L;
	/**
	 * IP是否可用状态，1可用
	 */
	public static final Integer STATUS_ABLE = 1;
	/**
	 * IP是否可用状态，0不可用
	 */
	public static final Integer STATUS_UNABLE = 0;
	
	/**
	 * IP是否可用状态，2全部不可用
	 */
	public static final Integer STATUS_ALL_UNABLE = 2;
	
	/**
	 * 代理IP, 不包括端口号
	 */
	private String ip;
	/**
	 * 代理IP端口号
	 */
	private Integer port;
	/**
	 * 提供的时间
	 */
	private Date offerTime = new Date();
	/**
	 * 使用的渠道标识ID
	 */
	private String channelId;
	/**
	 * 状态, 0代表不可用，1代理可用
	 */
	private Integer state = STATUS_ABLE;
	
	public ProxyIpDTO(){}
	
	public ProxyIpDTO(String ip, Integer port, String channelId){
		this.ip = ip;
		this.port = port;
		this.channelId = channelId;
	}
	public ProxyIpDTO(String ip, Integer port){
		this(ip, port, null);
	}
	
	public String getCompletionIP() {
		return getIp() + ":" + getPort();
	}
	
	public String getIp() {
		return ip;
	}
	public void setIp(String ip) {
		this.ip = ip;
	}
	public Integer getPort() {
		return port;
	}
	public void setPort(Integer port) {
		this.port = port;
	}
	public Date getOfferTime() {
		return offerTime;
	}
	public void setOfferTime(Date offerTime) {
		this.offerTime = offerTime;
	}
	public Integer getState() {
		return state;
	}
	public void setState(Integer state) {
		this.state = state;
	}
	public String getChannelId() {
		return channelId;
	}
	public void setChannelId(String channelId) {
		this.channelId = channelId;
	}
//	public String getProxyIp(){
//		return String.format("%s:%s", this.getIp(), this.getPort());
//	}
	/**
	 * 将代理IP标识为不可用
	 */
	public void changeUnable(){
		this.state = STATUS_UNABLE;
	}
	
}
